package com.glnz.spring6.resourceLoader;

import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import org.springframework.core.io.Resource;

/**
 * @Project ：learn_spring
 * @File ：ResourceLoaderDemo.java
 * @IDE ：IntelliJ IDEA
 * @Author ：自由如风间
 * @Date ：2025/4/6 11:11
 * @Description ：For study.
 */

public class ResourceLoaderDemo {

    @Test
    public void demo01() {
        ApplicationContext context = new ClassPathXmlApplicationContext();
        Resource resource = context.getResource("nothing.txt");
        System.out.println(resource.getFilename());
        System.out.println(resource.getDescription());
    }

    @Test
    public void demo02() {
        ApplicationContext context = new FileSystemXmlApplicationContext();
        Resource resource = context.getResource("nothing.txt");
        System.out.println(resource.getFilename());
        // file文件的Description的路径更完整
        System.out.println(resource.getDescription());
    }
}
